//
//  ZBProductSectionController.m
//  XZBProduct
//
//  Created by xzb on 2018/12/25.
//  Copyright © 2018 xzb. All rights reserved.
//

#import "ZBProductSectionController.h"
#import "ZBTextCell.h"
#import "ZBProductItem.h"
#import "ZBTextCellModel.h"

@interface ZBProductSectionController ()

@property (nonatomic, strong) ZBTextCellModel *textModel;

@end

@implementation ZBProductSectionController


-(NSInteger)numberOfItems{
    return 1;
}

-(CGSize)sizeForItemAtIndex:(NSInteger)index{
    return CGSizeMake(self.collectionContext.containerSize.width, 25);
}

-(UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index{
    
    ZBTextCell *cell = [self.collectionContext dequeueReusableCellOfClass:NSClassFromString(@"ZBTextCell") forSectionController:self atIndex:index];
    [cell bindViewModel:self.textModel];
    return cell;
}

- (void)didUpdateToObject:(ZBProductItem *)object
{
    NSParameterAssert([object isKindOfClass:[ZBProductItem class]]);
   
    ZBTextCellModel *textCellModel = [[ZBTextCellModel alloc] init];
    textCellModel.text = object.title;
    self.textModel = textCellModel;
}


@end
